<?php

class Disabler {
	public $disable = false;
}

class ValidatorDisabler extends sfValidatorPass
{
	protected $validator = null;
	protected $disabler;

	public function __construct(sfValidatorBase &$validator, Disabler &$disabler)
	{
		$this->validator = $validator;
		$this->disabler = $disabler;
		parent::__construct();
	}

	public function clean($value)
	{
		if ($this->disabler->disable) {
			return $value;
		}
		return $this->validator->clean($value);
	}
}
